﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="qlnewstype.ascx.cs" Inherits="admin_qlnewstype" %>
<style type="text/css">
    .style1
    {
        width: 370px;
    }
    .style2
    {
        width: 109px;
    }
</style>
<center>
<table width="100%">
    <tr>
        <th class="style2">&nbsp;</th>
        <th class="style1">
            Thêm Tin Mới</th>
        <th>
            &nbsp;</th>
    </tr>
    <tr>
        <td class="style2">Miêu tả: </td>
        <td class="style1">
            <asp:TextBox ID="des" runat="server" Height="93px" Width="334px" 
                MaxLength="5000" Rows="5" TextMode="MultiLine" ValidationGroup="insert"></asp:TextBox>
            <asp:HiddenField ID="hdfID" runat="server" />
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="des" ErrorMessage="*" ValidationGroup="insert">Chua nhập miêu tả</asp:RequiredFieldValidator>
            </td>
    </tr>
    <tr>
        <td class="style2"><center></center></td>
        <td class="style1">
            <asp:Button runat="server" ID="addbt" Text="Thêm" 
                onclick="addbt_Click" ValidationGroup="insert"/></td>
        <td>&nbsp;</td>
    </tr>
</table>
</center>
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" AllowSorting="True"
        CellPadding="4" ForeColor="#333333" GridLines="None"
        PageSize="5" Width="100%" onrowcreated="GridView1_RowCreated" 
        onrowediting="GridView1_RowEditing" 
    onrowcommand="GridView1_RowCommand" 
    DataSourceID="SqlDataSource1" DataKeyNames="id">
        <RowStyle BackColor="#EFF3FB" VerticalAlign="Middle" />
        <EmptyDataRowStyle VerticalAlign="Middle" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#459300" HorizontalAlign="Center" />
        <EmptyDataTemplate>
             <asp:Label ID="Label3" runat="server" Text="Chưa có dữ liệu"></asp:Label>
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="White" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#57A000" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="ID" SortExpression="id" 
                ItemStyle-HorizontalAlign="Center" Visible="False">
                <EditItemTemplate>
                    <asp:Label ID="id" runat="server" Text='<%# Eval("id") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="id" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Miêu tả" SortExpression="description">
                <EditItemTemplate>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        ControlToValidate="TextBox1" ErrorMessage="*">Chua nhập miêu tả</asp:RequiredFieldValidator>
                    <br />
                    <asp:TextBox ID="TextBox1" runat="server" Height="186px" Rows="5" 
                        Text='<%# Bind("description") %>' TextMode="MultiLine" Width="469px" 
                        MaxLength="5000"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("description") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:CommandField ButtonType="Button" EditText="Sửa" ShowEditButton="True" />
            <asp:CommandField ButtonType="Button" DeleteText="Xoá" 
                ShowDeleteButton="True" />
        </Columns>
        <EditRowStyle BackColor="#003366" VerticalAlign="Middle" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
    DeleteCommand="DELETE FROM [NewsType] WHERE [id] = @id" 
    InsertCommand="INSERT INTO [NewsType] ([id], [description]) VALUES (@id, @description)" 
    SelectCommand="SELECT [id], [description] FROM [NewsType] ORDER BY [id] DESC" 
    UpdateCommand="UPDATE [NewsType] SET [description] = @description WHERE [id] = @id">
    <DeleteParameters>
        <asp:Parameter Name="id" Type="Int64" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="description" Type="String" />
        <asp:Parameter Name="id" Type="Int64" />
    </UpdateParameters>
    <InsertParameters>
        <asp:ControlParameter ControlID="hdfID" Name="id" PropertyName="Value" 
            Type="Int64" />
        <asp:ControlParameter ControlID="des" Name="description" PropertyName="Text" 
            Type="String" />
    </InsertParameters>
</asp:SqlDataSource>